﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagicArenaFramework.GameObject.Components;

namespace MagicArenaFramework.GameObject.Attributes
{
    public class ScalarAttributeHolder : GoComposite
    {
        public delegate float ScalarWork(float arg);

        private Dictionary<UInt32, float> _Scalars = new Dictionary<UInt32, float>(5);

        public bool ValueFor(UInt32 family, out float value)
        {
            return _Scalars.TryGetValue(family, out value);
        }

        public void AddUpdateValue(UInt32 family, float value)
        {
            if (_Scalars.ContainsKey(family)) _Scalars[family] = value;
            else _Scalars.Add(family, value);
        }

        #region Composite overrides
        public bool AddChild(ScalarAttribute child)
        {
            AddUpdateValue(child.Family, child.Value);
            return base.AddChild(child);
        }
        #endregion
    }
}
